import requests
import config

class EmpAPI(object):
    def __init__(self):
        # 实例属性，emp_url:保存员工管理的url
        self.emp_url = config.BASE_URL + "/api/sys/user"

    def add_emp(self, body, au_headers):
        """
        功能：添加员工
        :param body: 添加员工的请求体
        :param au_headers: 请求头
        :return: 响应对象
        """
        response = requests.post(self.emp_url, json=body, headers=au_headers)
        return response

    def query_emp(self, query, au_headers):
        """
        功能：添加员工
        :param body: 添加员工的请求体
        :param au_headers: 请求头
        :return: 响应对象
        """
        response = requests.get(self.emp_url + '/' + query, headers=au_headers)
        return response

    def modify_emp(self, body, query, au_headers):
        """
        功能：添加员工
        :param body: 修改员工的请求体
        :param au_headers: 请求头
        :return: 响应对象
        """
        response = requests.put(self.emp_url + '/' + query, json=body, headers=au_headers)
        return response

    def delete_emp(self, query, au_headers):
        """
        功能：删除员工
        :param body: 添加员工的请求体
        :param au_headers: 请求头
        :return: 响应对象
        """
        response = requests.delete(self.emp_url + '/' + query, headers=au_headers)
        return response
